<template>
	<view>
		<!-- 选择企业公司 -->
		<uni-card>
			<view class="company">
				<picker @change="bindPickerChange" :range="companyDataList" range-key="companyName">
					<view class="companyContent">
						<view class="uni-input">
							{{companyList.communityName == 'dd' ? '选择企业公司' : companyDataList[companyList.communityName].companyName}}
						</view>
						<!-- <view class="iconsRight"> -->
						<uni-icons type="arrowright"></uni-icons>
						<!-- </view> -->
					</view>
				</picker>
			</view>
		</uni-card>
		<!-- 请输入您的姓名 -->
		<uni-card>
			<view class="choose">
				<input class="input" placeholder-class="coleles" v-model="companyList.userName" type="text" placeholder="请输入您的姓名" />
			</view>
		</uni-card>
		<!-- 请选择性别 -->
		<uni-card>
			<view class="choose">
				<!-- <input class="input" type="text" placeholder="请选择性别" /> -->
				<view style="">性别：</view>
				<view>
					<radio-group name="gender" @change="setCurrent" style="transform:scale(0.8);margin-left: -9px;">
						<label class="radio">
							<radio value="0" checked />男
						</label>
						<label class="radio" style="padding-left: 20px;">
							<radio value="1" />女
						</label>
					</radio-group>
					<!-- <radio-group name="gender" style="transform:scale(0.8);margin-left: -9px;" @change="companyList.sex = $event.detail.value">
							<label class="radio"> 
								<radio value="0" />男
							</label>
							<label class="radio" style="padding-left: 20rpx;">
								<radio value="1" />女
							</label>
						</radio-group> -->
				</view>

			</view>
		</uni-card>

		<button type="default" @tap="gomine">提交审核</button>
	</view>
</template>

<script>
	import login from "@/serve/api/login.js"
	import toMaintain from "@/serve/api/toMaintain.js"
	import {
		mapMutations
	} from "vuex"
	export default {
		data() {
			return {
				index: 0,
				pageNum: 1,
				getListFlag: true,
				companyDataList: [],
				plane: 0,
				companyList: { //身份认证
					communityName: "dd",
					userName: "",
				}
			}
		},
		onLoad(e) {
			this.getcompanyList(e.regionId)
		},
		methods: {
			...mapMutations(['setUserinfo']),
			setCurrent(e) {
				this.plane = e.detail.value
			},
			bindPickerChange(e) {
				console.log(e)
				this.$set(this.companyList, 'communityName', e.detail.value)
			},
			// 调用公司列表
			async getcompanyList() {
				let prams = {}
				const res = await login.findCompanyManageList();
				this.companyDataList = res.data.data.list
			},

			// 提交审核接口  companyDataList[companyList.communityName].companyId
			async gomine() {
				if (!this.companyDataList[this.companyList.communityName]) {
					uni.showToast({
						title: '请选择公司',
						icon: 'none'
					})
					return
				}
				if (this.companyList.userName == '') {
					uni.showToast({
						title: '请输入姓名',
						icon: 'none'
					})
					return
				}
				let parme = {
					attrId: this.companyDataList[this.companyList.communityName].companyId,
					userName: this.companyList.userName,
					sex: this.plane
				}
				const res = await login.identityAuthentication(parme);
				if (res) {
					const user = await toMaintain.selectSysUserById({
						flag: 1
					});
					if (user) {
						this.setUserinfo(user.data.data);
						uni.redirectTo({
							url: '/pages/register/identification/idaudit'
						})
					}
					
				}

			},
		}
	}
</script>

<style scoped>
	* {
		margin: 0;
		padding: 0;
	}

	page {
		width: 750rpx;
		background: #EFF2F5;
		overflow: hidden;
	}

	view {
		font-size: 28rpx;
		line-height: 1.8;

	}

	.uni-card {
		width: 670rpx;
		/* height: 96rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		border: none;
		margin: 0 auto;
		margin-top: 10px;

	}

	.choose {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		text-align: center;
	}

	.input {
		text-align: left;
		/* color:#ADB5C5 ; */
	}

	.company {
		/* display: flex; */
		flex-direction: row;
	}

	.companyContent {
		display: flex;
		flex-direction: row;
		width: 100%;
		justify-content: space-between;
		align-items: center;
	}

	.uni-input {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 400;

	}

	.iconsRight {
		display: inline-block;
	}

	.uni-icons {
		text-align: right;
	}

	/* 身份信息 */
	.idfront,
	.idreverse {
		/* width: 670rpx; */
		/* height: 352rpx; */
		background: #FFFFFF;
		box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(52, 54, 61, 0.05);
		border-radius: 16rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.idfront image {
		width: 450rpx;
		height: 220rpx;
		margin: 40rpx;
	}

	.idreverse image {
		width: 450rpx;
		height: 220rpx;
		margin: 40rpx;
	}

	button {
		width: 670rpx;
		height: 104rpx;
		background-color: #017EFE;
		box-shadow: 0rpx 20rpx 30rpx 0rpx rgba(1, 126, 254, 0.2);
		border-radius: 52rpx;
		margin: 0 auto;
		line-height: 104rpx;
		margin-top: 50rpx;
		font-size: 36rpx;
		text-align: center;
		font-weight: 400;
		color: #FFFFFF;
		letter-spacing: 10rpx;
		outline: none;
		border: 0;
		margin-bottom: 40rpx;
	}

	.coleles {
		color: #ADB5C5;
		font-size: 14px;
	}
</style>
